import request from '@/utils/request'

/**
 * 获取所有权限点
 * @returns {AxiosPromise}
 */
export function getAllPermission() {
  return request({
    url: '/sys/permission'
  })
}

/**
 * 添加权限点
 * @returns {AxiosPromise}
 */
export function addPermission(data) {
  return request({
    url: '/sys/permission',
    method: 'POST',
    data
  })
}

/**
 *根据ID获取权限点详情
 * @param id
 * @returns {AxiosPromise}
 */
export function getByIdPermission(id) {
  return request({
    url: `/sys/permission/${id}`,
    method: 'GET'
  })
}

/**
 *根据id删除权限点
 * @param id
 * @returns {AxiosPromise}
 */
export function delByIdPermission(id) {
  return request({
    url: `/sys/permission/${id}`,
    method: 'DELETE'
  })
}

/**
 * 更新权限点
 * @param id
 * @returns {AxiosPromise}
 */
export function updateByIdPermission(data) {
  return request({
    url: `/sys/permission/${data.id}`,
    method: 'PUT',
    data
  })
}

/**
 * 给角色分配权限
 * @param data
 * @returns {AxiosPromise}
 */
export function setPermission(data) {
  return request({
    url: `/sys/role/assignPrem`,
    method: 'PUT',
    data
  })
}

